home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / rkpls301.zip / RKPDEMO.ZIP / SAMPLE4.PAS < prev   
Pascal/Delphi Source File  |  1993-03-04  |  5KB  |  199 lines

  1. Program Sample4;
  2.  
  3. {
  4.  This is a sample programme using RkPlus.
  5.  It uses 2 registration levels (0 and 1).
  6.  If a Level 1 key has expired, it will be treated as Level 0.
  7.  If a Level 0 key has expired, it will be treated as Unregistered.
  8.  This is a very simple programme that doesn't actually do anything, but it
  9.  should demonstrate some of what can be done with RkPlus.
  10.  
  11.  It is identical to Sample1, except that it uses a "branding" programme
  12.  (such as Brand) to write the information directly into the EXE file,
  13.  rather than using a key file.  It uses the same keys as Sample1 (which
  14.  can be generated with GenKey).
  15.  
  16.  Sample4 uses the example encoding unit Encode.
  17. }
  18.  
  19.  
  20. Uses
  21.   Crt,
  22.   RkPlus,
  23.   Encode;
  24.  
  25.  
  26. Const
  27.   MonthNames : Array[1..12] of String[3]
  28.   = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
  29.  
  30.  
  31. Var
  32.   kc : Char;
  33.  
  34.  
  35. Procedure BadRegBeep;
  36.  
  37. Begin
  38.   Sound(1200);
  39.   Delay(200);
  40.   Sound(600);
  41.   Delay(200);
  42.   Sound(1200);
  43.   Delay(200);
  44.   Sound(600);
  45.   Delay(200);
  46.   NoSound;
  47. End;
  48.  
  49.  
  50. Procedure NotRegBeep;
  51.  
  52. Begin
  53.   Sound(600);
  54.   Delay(200);
  55.   Sound(1200);
  56.   Delay(200);
  57.   NoSound;
  58. End;
  59.  
  60.  
  61. Procedure DoView;
  62.  
  63. Begin
  64.   WriteLn('Sample data :');
  65.   WriteLn;
  66.   WriteLn('4.465536  7.918270  0.118373  5.367233');
  67.   WriteLn('1.396349  4.868343  7.079323  4.783021');
  68.   WriteLn('3.947924  8.864673  8.846264  2.999999');
  69.   WriteLn('8.490832  6.874378  5.338329  3.729270');
  70.   WriteLn('6.839882  8.873478  6.750373  7.018948');
  71.   WriteLn('5.034784  3.003763  3.253290  4.892387');
  72.   WriteLn('3.874378  8.314159  9.880869  3.987842');
  73.   WriteLn('2.764947  9.265358  4.013002  9.903278');
  74. End;
  75.  
  76.  
  77. Procedure DoCalc;
  78.  
  79. Begin
  80.   If Rkp.Registered then Begin
  81.     Write('The calculated result is ');
  82.     WriteLn(4.465536+7.918270+0.118373+5.367233+1.396349+4.868343+7.079323+4.783021
  83.     +3.947924+8.864673+8.846264+2.999999+8.490832+6.874378+5.338329+3.729270
  84.     +6.839882+8.873478+6.750373+7.018948+5.034784+3.003763+3.253290+4.892387
  85.     +3.874378+8.314159+9.880869+3.987842+2.764947+9.265358+4.013002+9.903278);
  86.   End Else
  87.     WriteLn('Only available in registered version!');
  88. End;
  89.  
  90.  
  91. Procedure DoTest;
  92.  
  93. Begin
  94.   If Rkp.Registered then Begin
  95.     If (Rkp.Level > 0) then Begin
  96.       Write('Performing tests...');
  97.       Delay(300);
  98.       WriteLn;
  99.       WriteLn('All tests passed.');
  100.     End Else
  101.       WriteLn('Not available in demo version!');
  102.   End Else
  103.     WriteLn('Only available in registered version!');
  104. End;
  105.  
  106.  
  107. Begin
  108.   If Not RkpOK then Begin
  109.     WriteLn('Unexpected Error ',RkpError,'!');
  110.     Halt(255);
  111.   End;
  112.   If BadSystemDate then Begin
  113.     WriteLn('You must correctly set your system clock to run Demo!');
  114.     BadRegBeep;
  115.     Halt(1);
  116.   End;
  117.   SetProgID('Sample');
  118.   VerifyKey;
  119.   Write('Sample4');
  120.   If Not RkpOK then
  121.     WriteLn(' [invalid]')
  122.   Else If Rkp.Registered and (Rkp.Level > 0) then
  123.     WriteLn(' [registered]')
  124.   Else If Rkp.Registered then
  125.     WriteLn(' [demo]')
  126.   Else
  127.     WriteLn(' [unregistered]');
  128.   WriteLn('Sample of RkPlus method 5 (with user-written encoding)');
  129.   WriteLn('See RKPLUS.DOC for more info');
  130.   WriteLn;
  131.   If (RkpError = InvalidFile) or (RkpError = InvalidKey) then Begin
  132.     WriteLn(ExeFileName,' has been altered!');
  133.     BadRegBeep;
  134.     Halt(1);
  135.   End Else If (RkpError = ExpiredKey) then Begin
  136.     If (Rkp.Level > 0) then Begin
  137.       WriteLn('Your registration key has expired!');
  138.       WriteLn('You will be given access at the DEMO level.');
  139.       NotRegBeep;
  140.       Rkp.Level := 0;
  141.     End Else Begin
  142.       WriteLn('Your limited use demo key has expired!');
  143.       WriteLn('You will be given access at the UNREGISTERED level.');
  144.       NotRegBeep;
  145.       Rkp.Registered := False;
  146.     End;
  147.   End Else If Rkp.Registered then Begin
  148.     If (Rkp.Level > 0) then Begin
  149.       WriteLn('This version of Sample4 is registered to ',Rkp.Name1);
  150.       If (Rkp.ExpYear <> 0) and (Rkp.ExpMonth <> 0) then
  151.         WriteLn('This registration will expire ','1-',MonthNames[Rkp.ExpMonth],'-',Rkp.ExpYear,'.');
  152.       WriteLn('Thank you for registering!');
  153.     End Else Begin
  154.       WriteLn('This version of Sample4 is a limited use demo for ',Rkp.Name1);
  155.       If (Rkp.ExpYear <> 0) and (Rkp.ExpMonth <> 0) then
  156.         WriteLn('This limited use demo will expire ','1-',MonthNames[Rkp.ExpMonth],'-',Rkp.ExpYear,'.');
  157.       WriteLn('Don''t forget to register!');
  158.     End;
  159.   End Else If Not RkpOK then Begin
  160.     WriteLn('Unexpected error ',RkpError,'!');
  161.     Halt(255);
  162.   End Else Begin
  163.     WriteLn('This version of Sample4 is unregistered.');
  164.     NotRegBeep;
  165.     Delay(500);
  166.   End;
  167.   WriteLn;
  168.   WriteLn('Sample4 Menu');
  169.   WriteLn;
  170.   WriteLn('[V]iew sample data');
  171.   Write('[C]alculate');
  172.   If Not Rkp.Registered then
  173.     WriteLn('  (only available in registered version)')
  174.   Else
  175.     WriteLn;
  176.   Write('[T]est results');
  177.   If Not Rkp.Registered then
  178.     WriteLn('  (only available in registered version)')
  179.   Else If (Rkp.Level <= 0) then
  180.     WriteLn('  (not available in demo version)')
  181.   Else
  182.     WriteLn;
  183.   WriteLn;
  184.   Write('Selection : ');
  185.   kc := UpCase(ReadKey);
  186.   WriteLn;
  187.   WriteLn;
  188.   Case kc of
  189.   'V' :
  190.     DoView;
  191.   'C' :
  192.     DoCalc;
  193.   'T' :
  194.     DoTest;
  195.   Else
  196.     WriteLn('Invalid selection!');
  197.   End;
  198. End.
  199.